﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Text.RegularExpressions;
using System.Net;
using System.Reflection;

namespace ACSkins.Controls
{
    public partial class ACSkinIPAddBox : UserControl
    {
        public ACSkinIPAddBox()
        {
            InitializeComponent();
        }

        [Description("IP地址"),Category("自定义")]
        public string IPAddress
        {
            get 
            {
                return new IPAddress(new byte[4] { Convert.ToByte(t1.Text), Convert.ToByte(t2.Text), Convert.ToByte(t3.Text), Convert.ToByte(t4.Text) }).ToString();
            }
            set
            {
                if (Regex.IsMatch(value, @"^((2[0-4]\d|25[0-5]|[01]?\d\d?)\.){3}(2[0-4]\d|25[0-5]|[01]?\d\d?)$"))
                {
                    t1.Text = value.Split('.')[0];
                    t2.Text = value.Split('.')[1];
                    t3.Text = value.Split('.')[2];
                    t4.Text = value.Split('.')[3];
                }
            }
        }

        private void t1_KeyPress(object sender, KeyPressEventArgs e)
        {
            
        }

        private void t2_KeyPress(object sender, KeyPressEventArgs e)
        {

        }

        private void t3_KeyPress(object sender, KeyPressEventArgs e)
        {

        }

        private void t4_KeyPress(object sender, KeyPressEventArgs e)
        {

        }
    }
}
